package main

import "fmt"

/*
golang中 空接口和类型断言使用细节
*/

type Address struct {
	Name  string
	Phone int
}

func main() {

	var userInfo = make(map[string]interface{})
	userInfo["name"] = "张三"
	userInfo["age"] = 18
	userInfo["hobby"] = []string{"唱歌", "跳舞", "打豆豆"}

	fmt.Println(userInfo)

	var address = Address{
		Name:  "李四",
		Phone: 123456,
	}
	fmt.Println(address.Name) // 李四

	userInfo["address"] = address

	// var name = useInfo["address"].name  报错 不能这样
	hobby2, _ := userInfo["hobby"].([]string) //类型断言

	fmt.Println(hobby2[1]) //跳舞
}
